package com.ymatou.iapi.refund.testcase;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.common.collect.Lists;
import com.ymatou.iapi.optrade.parameter.enums.CancelOrderTypeEnum;
import com.ymatou.iapi.optrade.resp.Order;
import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymatou.iapi.refund.parameter.CreateReturnBillBean;
import com.ymatou.iapi.refund.parameter.CreateReturnBillResp.ReturnBillList;
import com.ymatou.iapi.refund.parameter.ProductCatalogModel;
import com.ymatou.iapi.refund.parameter.ProductRefundAmountInfo;
import com.ymatou.iapi.refund.service.CreateReturnBillCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.RefundCallService;
import com.ymttest.business.service.YMTTrading.TradingCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceEngageOrderCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceOrderCallService;
import com.ymttest.database.model.CS_FastReturnLog;
import com.ymttest.database.model.CS_ReturnApplyBill;
import com.ymttest.database.model.CS_ReturnApplyBillLog;
import com.ymttest.database.model.CS_ReturnApplyPictures;
import com.ymttest.database.model.CS_ReturnApplyProducts;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.sharding.db.sharding.model.OrderDetailPo;
import com.ymttest.database.sharding.db.sharding.model.OrderPo;
import com.ymttest.database.sharding.db.sqlwapper.OrderShardingWapper;
import com.ymttest.database.sqlwapper.CS_FastReturnLogWapper;
import com.ymttest.database.sqlwapper.CS_ReturnApplyBillLogWapper;
import com.ymttest.database.sqlwapper.CS_ReturnApplyBillWapper;
import com.ymttest.database.sqlwapper.CS_ReturnApplyPicturesWapper;
import com.ymttest.database.sqlwapper.CS_ReturnApplyProductsWapper;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.TestDataManager;

/**
 * 创建退货记录 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_CreateReturnBill {
	private static CreateReturnBillBean bean;
	private static CreateReturnBillCall call;
	private static CS_ReturnApplyBillWapper returnApplyBillWapper = new CS_ReturnApplyBillWapper();
	private static CS_ReturnApplyProductsWapper returnApplyProductsWapper = new CS_ReturnApplyProductsWapper();
	private static CS_ReturnApplyPicturesWapper returnApplyPictures = new CS_ReturnApplyPicturesWapper();
	private static CS_ReturnApplyBillLogWapper returnApplyBillLog = new CS_ReturnApplyBillLogWapper();
	private static CS_FastReturnLogWapper fastReturnLog = new CS_FastReturnLogWapper();
	private static YmtCatalogsIWapper cwapper = new YmtCatalogsIWapper();
	private static OrderShardingWapper orderShardingWapper = new OrderShardingWapper();

	private RefundCallService service = new RefundCallService();
	private TradingCallService tradingService = new TradingCallService();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("创建退货记录");

	}

	@Before
	public void caseUp() {
		bean = new CreateReturnBillBean();
		call = new CreateReturnBillCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_001() {
		Logger.start(true, "正例-创建退货记录-一个商家，一个商品，一个订单");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);

			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			Thread.sleep(5000);
			service.callCreateReturnBill(bean, call);
			// bean.setOrderId(1120015549);
			// bean.setUserid(24715549);
			// bean.setReturnAmount(new BigDecimal(7));
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_001_1() {
		Logger.start(true, "正例-创建退货记录-未接单-直接走取消流程，退单日志中仅记录发起和退款完成");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			Thread.sleep(5000);
			service.callCreateReturnBill(bean, call);
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_001_2() {
		Logger.start(true, "正例-创建退货记录-一个商家，一个商品，一个订单-微信支付退单");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			// ###########bean 开始################
			String num = TestDataManager.getRandomNum(5);
			List<Order> orders = tradingServiceResp.getOrderList();
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);
			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();

			BigDecimal returnAmount = tradingServiceResp.getPayableAmount();
			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##returnAmount##:" + returnAmount);
			Logger.comment("##totalPrice ##:"
					+ tradingServiceResp.getPayableAmount());

			String catalogId = orders.get(0).getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount();
			// 订单支付
			TradingCallService.payOrder((long) userId, new BigDecimal(0),
					tradingServiceResp.getTradingId(), false, returnAmount,
					new BigDecimal(5));
			// tradingService.payOrder(userId,returnAmount,tradingServiceResp.getTradingId());

			bean.setOrderId(orderId);
			bean.setReturnAmount(returnAmount);
			bean.setReturnRemark("自动化测试");
			bean.setReturnReasonId(1);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);
			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			bean.setProducts(products);
			Thread.sleep(10000);
			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(order.getSellerId(), orderId);
			// ###########bean 结束################
			service.callCreateReturnBill(bean, call);
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_002() {
		Logger.start(true, "正例-创建退货记录-一个商家，一个商品，一个订单,使用优惠券");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithCoupon();
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			service.callCreateReturnBill(bean, call);
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_003() {
		Logger.start(false, "正例-创建退货记录-一个商家，一个商品，一个订单,砍价团商品(已成团的订单不能取消)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithBargainGroup(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, true);
			service.callCreateReturnBill(bean, call);
			// verifyReturn(tradingServiceResp,bean,call);
			Logger.verifyEquals(
					true,
					call.getMsg1().contains(
							"哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款"), "验证Msg");
			Logger.verifyEquals("201", call.getStatus(), "验证Status");
			Logger.verifyEquals("1", call.getbCode(), "验证bCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_004() {
		Logger.start(false, "反例-创建退货记录-一个商家，一个商品，一个订单,砍价团商品又使用优惠券（已成团的订单不能取消）");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();

			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithBargainGroup(true);

			RefundCallService service = new RefundCallService();
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, true);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(
					true,
					call.getMsg1().contains(
							"哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款"), "验证Msg");
			Logger.verifyEquals("201", call.getStatus(), "验证Status");
			Logger.verifyEquals("1", call.getbCode(), "验证bCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_005() {
		Logger.start(true, "正例-创建退货记录-1个买手,多商品,生成2个订单,退第一个订单的第一个商品");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithTwoProcutInOneOrder(false, false);
			bean = service.setCreateReturnBillMoreBean_AcceptOrder(
					tradingServiceResp, tradingService);

			service.callCreateReturnBill(bean, call);
			// 哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_005_1() {
		Logger.start(true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,退第一个订单的第一个商品退成功，第二次申请退第二个商品");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithTwoProcutInOneOrder(false, false);
			bean = service.setCreateReturnBillMoreBean_AcceptOrder(
					tradingServiceResp, tradingService);
			service.callCreateReturnBill(bean, call);// 第一次申请退款

			String num = TestDataManager.getRandomNum(5);

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();
			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##payAmount##:" + payAmount);

			String catalogId = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(1)
					.getProductCount();

			// //订单支付
			// tradingService.payOrder(userId,payAmount,tradingServiceResp.getTradingId());

			bean.setOrderId(orderId);
			bean.setReturnAmount(order.getOrderDetailPoList().get(1)
					.getProductPrice());
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			bean.setProducts(products);

			service.callCreateReturnBill(bean, call);// 第二次申请退款
			// verifyReturn(tradingServiceResp,bean,call,2);

			CheckCS_ReturnApplyBill2(tradingServiceResp, bean, call);
			CheckCS_ReturnApplyProducts2(tradingServiceResp, bean, call);
			CheckCS_ReturnApplyPictures(tradingServiceResp, bean, call);
			CheckCS_ReturnApplyBillLog(tradingServiceResp, bean, call);
			CheckCS_FastReturnLog(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_006() {
		Logger.start(true, "正例-创建退货记录-1个买手,多商品,生成2个订单,退第二个订单");
		try {
			// 创建一个订单
			TradingCallService tradingService = new TradingCallService();
			// placeOrder3 方法是3个商品，前两个商品是一个订单，后一个商品是一个订单
			TradingServiceResp tradingServiceResp = TradingPlaceOrderCallService
					.placeOrderWithTwoProcutInOneOrder(false, false);

			List<Order> orders = tradingServiceResp.getOrderList();
			long orderId = orders.get(1).getOrderId();
			int userId = (int) tradingServiceResp.getUserId();
			BigDecimal returnAmount = tradingServiceResp.getPayableAmount();
			Logger.comment("##orderId##:" + orderId);

			String catalogId1 = orders.get(1).getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount1 = orders.get(1).getOrderDetailPoList().get(0)
					.getProductCount();

			// 订单支付
			tradingService.payOrder(userId, returnAmount,
					tradingServiceResp.getTradingId());

			bean.setOrderId(orderId);
			bean.setReturnAmount(new BigDecimal(3));
			bean.setReturnRemark("自动化测试");
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);

			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();

			productModel.setCatalogId(catalogId1);
			productModel.setReturnCount(returnCount1);
			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			bean.setProducts(products);

			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			tradingService.sellerAcceptOrder(catalog.getiUserId(), orderId);
			Thread.sleep(3000);
			call.setData(bean);
			call.callService();
			verifyReturn(tradingServiceResp, bean, call, 2);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_009() {
		Logger.start(false, "反例-创建退货记录-已经申请退货，再次申请退货");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);

			service.callCreateReturnBill(bean, call);
			call.callService();
			Logger.verifyEquals(true,
					call.getMsg1().contains("商品已经申请过退款，不需要重复申请"), "验证Msg");
			Logger.verifyEquals("8", call.getbCode(), "验证bCode");
			Logger.verifyEquals("500", call.getStatus(), "验证Status");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_010() {
		Logger.start(false, "正例-创建退货记录-订单主动取消，申请退货");
		try {
			// 创建一个订单
			TradingCallService tradingService = new TradingCallService();
			TradingServiceResp tradingServiceResp = TradingPlaceOrderCallService
					.placeOrderWithLuxury(false);

			List<Order> orders = tradingServiceResp.getOrderList();
			long orderId = orders.get(0).getOrderId();
			long userId = tradingServiceResp.getUserId();
			// 取消订单
			tradingService.cancelOrder(orderId,
					CancelOrderTypeEnum.BUYER_CANCEL_ORDER, userId);
			Logger.comment("##orderId##:" + orderId);

			String catalogId = orders.get(0).getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = orders.get(0).getOrderDetailPoList().get(0)
					.getProductCount();

			bean.setOrderId(orderId);
			bean.setReturnAmount(new BigDecimal(3));
			bean.setReturnRemark("自动化测试");
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid((int) userId);
			bean.setIsYMTHandle(false);
			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);
			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			bean.setProducts(products);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals(
					true,
					call.getMsg1().contains(
							"订单"
									+ tradingServiceResp.getOrderList().get(0)
											.getOrderId() + "已取消，不能退货退款"),
					"验证Msg");
			Logger.verifyEquals("201", call.getStatus(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_011() {
		Logger.start(false, "正例-创建退货记录-一个规格商品,订单已接单，申请退货(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_012() {
		Logger.start(false, "反例-创建退货记录-多个规格商品,订单未接单，部分申请退货(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingCallService tradingService = new TradingCallService();

			TradingServiceResp tradingServiceResp = TradingPlaceOrderCallService
					.placeOrderWithTwoProcutInOneOrder(false, false);

			String num = TestDataManager.getRandomNum(5);
			bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);
			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();
			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##payAmount##:" + payAmount);
			Logger.comment("##tradingServiceResp##:"
					+ tradingServiceResp.getOrderList().size());

			String catalogId1 = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(0)
					.getProductCount();

			String catalogId2 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			// String
			// catalogId3=order.getOrderDetailPoList().get(2).getCatalogId();
			// int
			// returnCount3=order.getOrderDetailPoList().get(2).getProductCount();

			// 订单支付
			tradingService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			bean.setOrderId(orderId);
			bean.setReturnAmount(order.getOrderPayableAmount());
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId1);
			productModel.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			// ProductCatalogModel productModel3=new ProductCatalogModel();
			// productModel3.setCatalogId(catalogId3);
			// productModel3.setReturnCount(returnCount3);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel2);
			// products.add(productModel3);
			bean.setProducts(products);

			Thread.sleep(3000);

			call.setData(bean);
			call.callService();
			Logger.verifyEquals(true, call.getMsg1().contains("退款商品不正确"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_013() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单未接单，申请退货，退款商品数量填写不正确(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			bean.getProducts().get(0).setReturnCount(9999999);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("退款商品数量填写不正确"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_017() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单已接单，申请退货，退款商品数量填写不正确(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			bean.getProducts().get(0).setReturnCount(9999999);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("退货数量填写不正确"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_014() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单未接单，申请退货，退款金额大于实际退款金额(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			bean.setReturnAmount(returnAmount.add(new BigDecimal(1)));
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true,
					call.getMsg1().contains("退款金额填写不正确!最大可退金额" + returnAmount),
					"验证Msg");
			Logger.verifyEquals("500", call.getStatus(), "验证Status");
			Logger.verifyEquals("5", call.getbCode(), "验证bCode");
			// verifyReturn(tradingServiceResp,bean,call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_018() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单已接单，申请退货，退款金额大于实际退款金额(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);

			bean.setReturnAmount(bean.getReturnAmount().add(new BigDecimal(1)));
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true,
					call.getMsg1().contains("申请退款金额不能大于实际可退款金额"), "验证Msg");
			Logger.verifyEquals("201", call.getStatus(), "验证Status");
			Logger.verifyEquals("1", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_015() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单未接单，申请退货，退款金额小于实际退款金额(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			bean.setReturnAmount(returnAmount.subtract(new BigDecimal(1)));
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true,
					call.getMsg1().contains("退款金额填写不正确!最大可退金额" + returnAmount),
					"验证Msg");
			Logger.verifyEquals("500", call.getStatus(), "验证Status");
			Logger.verifyEquals("5", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_019() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单已接单，申请退货，退款金额小于实际退款金额(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			bean.setReturnAmount(returnAmount.subtract(new BigDecimal(1)));
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_020() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单已接单，申请退货，退款金额小于0(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setReturnAmount(new BigDecimal(-1));
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("请输入正确的退款金额"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_021() {
		Logger.start(false,
				"正例-创建退货记录-一个规格商品,订单已接单，申请退货，退款金额等于0(直接走取消流程,取消要看商品规格数量)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setReturnAmount(new BigDecimal(0));
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("请输入正确的退款金额"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_016() {
		Logger.start(false, "正例-创建退货记录-无效的订单");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setOrderId(9999999);
			;
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("无效的订单"), "验证Msg");
			Logger.verifyEquals("500", call.getStatus(), "验证Status");
			Logger.verifyEquals("6", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_022() {
		Logger.start(false, "正例-创建退货记录-退货退款描述最大字符-不能大于500字符");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			String remark = "";
			for (int i = 0; i < 501; i++)
				remark = remark + "A";

			bean.setReturnRemark(remark);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true,
					call.getMsg1().contains("退货备注不能大于500字符(250汉字)!"), "验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_023() {
		Logger.start(false, "正例-创建退货记录-退货退款描述最大字符-等于500字符");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			String remark = "";
			for (int i = 0; i < 500; i++)
				remark = remark + "A";

			bean.setReturnRemark(remark);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_024() {
		Logger.start(false, "正例-创建退货记录-退货退款描述最大字符-不能大于250汉字");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			String remark = "";
			for (int i = 0; i < 251; i++)
				remark = remark + "测";

			bean.setReturnRemark(remark);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true,
					call.getMsg1().contains("退货备注不能大于500字符(250汉字)!"), "验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_025() {
		Logger.start(false, "正例-创建退货记录-退货退款描述最大字符-等于250汉字");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			String remark = "";
			for (int i = 0; i < 250; i++)
				remark = remark + "测";

			bean.setReturnRemark(remark);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_026() {
		Logger.start(false, "正例-创建退货记录-退货原因及类型-类型不存在");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setReturnReasonId(9999);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("无效的退款原因"),
					"验证Msg");
			Logger.verifyEquals("500", call.getStatus(), "验证Status");
			Logger.verifyEquals("9", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_027() {
		Logger.start(false, "正例-创建退货记录-已接单,申请类型(0=退款)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setReturnType(0);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_027_1() {
		Logger.start(false, "正例-创建退货记录-未接单,申请类型(0=退款)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setReturnType(0);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_028() {
		Logger.start(false, "正例-创建退货记录-已接单,申请类型(1=退货退款)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean_AcceptOrder(
					tradingServiceResp, tradingService, false);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setReturnType(1);
			service.callCreateReturnBill(bean, call);

			// verifyReturn(tradingServiceResp,bean,call);

			Logger.verifyEquals(true, call.getMsg1().contains("只能发起仅退款"),
					"验证Msg");
			Logger.verifyEquals("500", call.getStatus(), "验证Status");
			Logger.verifyEquals("9", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_028_1() {
		Logger.start(false, "正例-创建退货记录-未接单,申请类型(1=退货退款)");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setReturnType(1);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);

			// Logger.verifyEquals(true,call.getMsg1().contains("只能发起仅退款"),
			// "验证Msg");
			// Logger.verifyEquals("500",call.getStatus(), "验证Status");
			// Logger.verifyEquals("9",call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_029() {
		Logger.start(false, "反例-创建退货记录-买家用户为空");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setUserid(0);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("请传入用户Id"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_030() {
		Logger.start(false, "反例-创建退货记录-买家用户不存在");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setUserid(9999999);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("无效的订单"), "验证Msg");
			Logger.verifyEquals("500", call.getStatus(), "验证Status");
			Logger.verifyEquals("6", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_031() {
		Logger.start(false, "反例-创建退货记录-IsYMTHandle=true，是洋码头介入");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setIsYMTHandle(true);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_032() {
		Logger.start(false, "反例-创建退货记录-PicUrls，图片链接为空");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setPicUrls(null);
			service.callCreateReturnBill(bean, call);

			verifyReturn(tradingServiceResp, bean, call);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_033() {
		Logger.start(false, "反例-创建退货记录-products，退货商品列表为空");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.setProducts(null);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("申请退款失败"),
					"验证Msg");
			Logger.verifyEquals("201", call.getStatus(), "验证Status");
			Logger.verifyEquals("1", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_034() {
		Logger.start(false, "反例-创建退货记录-products-CatalogId，CatalogId为空");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.getProducts().get(0).setCatalogId("");
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("请传入商品规格Id"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_035() {
		Logger.start(false, "反例-创建退货记录-products-CatalogId，CatalogId不存在");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			bean = service.setCreateReturnBillBean(tradingServiceResp,
					tradingService);
			BigDecimal returnAmount = bean.getReturnAmount();
			// 验证参数
			bean.getProducts().get(0).setCatalogId("121231241");
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true, call.getMsg1().contains("退款商品不正确"),
					"验证Msg");
			Logger.verifyEquals("400", call.getStatus(), "验证Status");
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_036() {
		Logger.start(true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,验证未接单，退第一个订单的多个商品-其中订单的数量 与实际数据相等-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);

			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##TradingId##:" + tradingServiceResp.getTradingId());
			Logger.comment("##payAmount##:"
					+ tradingServiceResp.getPayableAmount());

			// List<OrderPo> orders= orderShardingWapper
			// .selectOrderbyMainOrderId(tradingServiceResp.getPayableAmount());

			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount();

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			String catalogId2 = order.getOrderDetailPoList().get(2)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(2)
					.getProductCount();

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			BigDecimal retrunPayAmount = orderShardingWapper
					.selectOrderbyOrderId(orderId).getPayableAmount();

			bean.setOrderId(orderId);
			bean.setReturnAmount(retrunPayAmount);
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel1);
			products.add(productModel2);

			bean.setProducts(products);

			// //商家接单
			// YmtCatalogsI
			// catalog=cwapper.selectCatalogsByCatalogId(bean.getProducts().get(0).getCatalogId());
			// tradingService.sellerAcceptOrder(catalog.getiUserId(),orderId);

			// Thread.sleep(5000);

			service.callCreateReturnBill(bean, call);
			// 哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_CreateReturnBill_038() {
		Logger.start(
				true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,验证未接单，退第一个订单的多个商品-其中第一个商品的数量小于第一个商品的总数量-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);

			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##TradingId##:" + tradingServiceResp.getTradingId());
			Logger.comment("##payAmount##:"
					+ tradingServiceResp.getPayableAmount());

			// List<OrderPo> orders= orderShardingWapper
			// .selectOrderbyMainOrderId(tradingServiceResp.getPayableAmount());

			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount() - 1;

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			String catalogId2 = order.getOrderDetailPoList().get(2)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(2)
					.getProductCount();

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			BigDecimal retrunPayAmount = orderShardingWapper
					.selectOrderbyOrderId(orderId).getPayableAmount();

			bean.setOrderId(orderId);
			bean.setReturnAmount(retrunPayAmount);
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel1);
			products.add(productModel2);

			bean.setProducts(products);

			// //商家接单
			// YmtCatalogsI
			// catalog=cwapper.selectCatalogsByCatalogId(bean.getProducts().get(0).getCatalogId());
			// tradingService.sellerAcceptOrder(catalog.getiUserId(),orderId);

			// Thread.sleep(5000);

			service.callCreateReturnBill(bean, call);
			// 哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款
			// verifyReturn(tradingServiceResp,bean,call);
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
			Logger.verifyEquals("4", call.getStatus(), "验证Status");
			Logger.verifyEquals(true, call.getMsg1().contains("退款商品数量填写不正确"),
					"验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_CreateReturnBill_039() {
		Logger.start(
				true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,验证未接单，退第一个订单的多个商品,其中第一个商品的数量大于第一个商品的总数量-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);
			// bean=service.setCreateReturnBillMoreBean_AcceptOrder(tradingServiceResp,tradingService);
			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##TradingId##:" + tradingServiceResp.getTradingId());
			Logger.comment("##payAmount##:"
					+ tradingServiceResp.getPayableAmount());

			// List<OrderPo> orders= orderShardingWapper
			// .selectOrderbyMainOrderId(tradingServiceResp.getPayableAmount());

			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount();

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			String catalogId2 = order.getOrderDetailPoList().get(2)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(2)
					.getProductCount();

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			BigDecimal retrunPayAmount = orderShardingWapper
					.selectOrderbyOrderId(orderId).getPayableAmount();

			bean.setOrderId(orderId);
			bean.setReturnAmount(retrunPayAmount);

			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel1);
			products.add(productModel2);

			bean.setProducts(products);

			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog.getiUserId(), orderId);

			YmtCatalogsI catalog1 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(1).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog1.getiUserId(), orderId);

			YmtCatalogsI catalog2 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(2).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog2.getiUserId(), orderId);

			// Thread.sleep(10000);

			service.callCreateReturnBill(bean, call);
			// 哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_037() {
		Logger.start(true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,验证已接单，退第一个订单的多个商品,其中第一个订单的数量等于商品的总数量-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);

			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##TradingId##:" + tradingServiceResp.getTradingId());
			Logger.comment("##payAmount##:"
					+ tradingServiceResp.getPayableAmount());

			// List<OrderPo> orders= orderShardingWapper
			// .selectOrderbyMainOrderId(tradingServiceResp.getPayableAmount());

			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount();

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			String catalogId2 = order.getOrderDetailPoList().get(2)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(2)
					.getProductCount();

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			BigDecimal retrunPayAmount = orderShardingWapper
					.selectOrderbyOrderId(orderId).getPayableAmount();

			bean.setOrderId(orderId);
			bean.setReturnAmount(retrunPayAmount);
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel1);
			products.add(productModel2);

			bean.setProducts(products);

			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog.getiUserId(), orderId);

			YmtCatalogsI catalog1 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(1).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog1.getiUserId(), orderId);

			YmtCatalogsI catalog2 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(2).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog2.getiUserId(), orderId);

			Thread.sleep(10000);

			service.callCreateReturnBill(bean, call);
			// 哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_040() {
		Logger.start(true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,验证已接单，退第一个订单的多个商品,其中第一个数量小于商品的总数量-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);
			
			// bean=service.setCreateReturnBillMoreBean_AcceptOrder(tradingServiceResp,tradingService);
			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();
			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##payAmount##:" + payAmount);

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount();// 修改值

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			String catalogId2 = order.getOrderDetailPoList().get(2)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(2)
					.getProductCount();

			if (returnCount - 1 > 0)
				returnCount = returnCount - 1;
			else if (returnCount1 - 1 > 0)
				returnCount1 = returnCount1 - 1;
			else if (returnCount2 - 1 > 0)
				returnCount2 = returnCount2 - 1;

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			bean.setOrderId(orderId);
			bean.setReturnAmount(order.getOrderDetailPoList().get(0)
					.getProductPrice());
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel1);
			products.add(productModel2);

			bean.setProducts(products);

			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog.getiUserId(), orderId);

			YmtCatalogsI catalog1 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(1).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog1.getiUserId(), orderId);

			YmtCatalogsI catalog2 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(2).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog2.getiUserId(), orderId);

			Thread.sleep(5000);

			service.callCreateReturnBill(bean, call);
			// 哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款
			verifyReturn(tradingServiceResp, bean, call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_040_1() {
		Logger.start(
				true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,验证已接单，退第一个订单的多个商品,第一次退一个商品，第二次再申请退另外一个商品-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);
			// bean=service.setCreateReturnBillMoreBean_AcceptOrder(tradingServiceResp,tradingService);
			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();
			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##payAmount##:" + payAmount);

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount();

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			bean.setOrderId(orderId);
			bean.setReturnAmount(order.getOrderDetailPoList().get(0)
					.getProductPrice()); // 可退最大金额
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			bean.setProducts(products);

			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog.getiUserId(), orderId);

			// Thread.sleep(10000);
			service.callCreateReturnBill(bean, call);

			// 第二次申请退款
			Logger.comment("############第二次申请退款###########");
			bean.setReturnAmount(order.getOrderDetailPoList().get(1)
					.getProductPrice()); // 可退最大金额
			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(1);
			List<ProductCatalogModel> products1 = new ArrayList<ProductCatalogModel>();
			products1.add(productModel1);
			bean.setProducts(products1);

			YmtCatalogsI catalog1 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog1.getiUserId(), orderId);
			service.callCreateReturnBill(bean, call);
			// 哈尼，已成团的订单不能取消，如有商品质量问题，可在收到货物后，申请退货退款
			// verifyReturn(tradingServiceResp,bean,call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_040_2() {
		Logger.start(
				true,
				"正例-创建退货记录-1个买手,多商品,生成2个订单,验证已接单，退第一个订单的多个商品,其中申请的退款 大于商品最大与退金额，多的部分就是运费-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);
			// bean=service.setCreateReturnBillMoreBean_AcceptOrder(tradingServiceResp,tradingService);
			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();
			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##payAmount##:" + payAmount);

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount();// 修改值
			BigDecimal returnAmount = order.getOrderDetailPoList().get(0)
					.getProductPrice().multiply(new BigDecimal(returnCount));

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();
			BigDecimal returnAmount1 = order.getOrderDetailPoList().get(1)
					.getProductPrice().multiply(new BigDecimal(returnCount1));

			String catalogId2 = order.getOrderDetailPoList().get(2)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(2)
					.getProductCount();
			BigDecimal returnAmount2 = order.getOrderDetailPoList().get(2)
					.getProductPrice().multiply(new BigDecimal(returnCount2));

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			BigDecimal returnAmount_sum = returnAmount.add(returnAmount1).add(
					returnAmount2);

			bean.setOrderId(orderId);
			bean.setReturnAmount(returnAmount_sum.add(new BigDecimal(10)));
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel1);
			products.add(productModel2);

			bean.setProducts(products);

			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog.getiUserId(), orderId);

			YmtCatalogsI catalog1 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(1).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog1.getiUserId(), orderId);

			YmtCatalogsI catalog2 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(2).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog2.getiUserId(), orderId);

			// Thread.sleep(10000);

			service.callCreateReturnBill(bean, call);

			// verifyReturn(tradingServiceResp,bean,call);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_041() {
		Logger.start(false,
				"反例-创建退货记录-1个买手,多商品,生成2个订单,验证已接单，退第一个订单的多个商品,其中第一个订单的数量大于商品的总数量-JIRACONN-23002");
		try {
			// 创建一个订单
			TradingPlaceOrderCallService tradingService=new TradingPlaceOrderCallService();
			RefundCallService service=new RefundCallService();
			TradingServiceResp tradingServiceResp=tradingService.placeOrderWithTwoProcutInOneOrder(false, false);
			// bean=service.setCreateReturnBillMoreBean_AcceptOrder(tradingServiceResp,tradingService);
			String num = TestDataManager.getRandomNum(5);
			CreateReturnBillBean bean = new CreateReturnBillBean();

			Order order = tradingServiceResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			int userId = (int) tradingServiceResp.getUserId();
			BigDecimal payAmount = tradingServiceResp.getPayableAmount();

			Logger.comment("##orderId##:" + orderId);
			Logger.comment("##payAmount##:" + payAmount);

			String catalogId = order.getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = order.getOrderDetailPoList().get(0)
					.getProductCount() + 1;// 修改值

			String catalogId1 = order.getOrderDetailPoList().get(1)
					.getCatalogId();
			int returnCount1 = order.getOrderDetailPoList().get(1)
					.getProductCount();

			String catalogId2 = order.getOrderDetailPoList().get(2)
					.getCatalogId();
			int returnCount2 = order.getOrderDetailPoList().get(2)
					.getProductCount();

			// 订单支付
			TradingCallService.payOrder(userId, payAmount,
					tradingServiceResp.getTradingId());

			bean.setOrderId(orderId);
			bean.setReturnAmount(order.getOrderDetailPoList().get(0)
					.getProductPrice());
			bean.setReturnRemark("自动化测试申请退货单_" + num);
			bean.setReturnReasonId(137);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid(userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);

			ProductCatalogModel productModel1 = new ProductCatalogModel();
			productModel1.setCatalogId(catalogId1);
			productModel1.setReturnCount(returnCount1);

			ProductCatalogModel productModel2 = new ProductCatalogModel();
			productModel2.setCatalogId(catalogId2);
			productModel2.setReturnCount(returnCount2);

			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			products.add(productModel1);
			products.add(productModel2);

			bean.setProducts(products);

			// 商家接单
			YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(0).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog.getiUserId(), orderId);

			YmtCatalogsI catalog1 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(1).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog1.getiUserId(), orderId);

			YmtCatalogsI catalog2 = cwapper.selectCatalogsByCatalogId(bean
					.getProducts().get(2).getCatalogId());
			TradingCallService.sellerAcceptOrder(catalog2.getiUserId(), orderId);

			// Thread.sleep(10000);

			service.callCreateReturnBill(bean, call);
			Logger.verifyEquals("12", call.getbCode(), "验证bCode");
			Logger.verifyEquals("400", call.getStatus(), "验证Status(");
			Logger.verifyEquals(true, call.getMsg1().contains("退货数量填写不正确"),
					"验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_044() {
		Logger.start(true, "正例-创建退货记录--预售商品退货退款");
		try {
			// 创建一个预售的订单
			TradingServiceResp placeOrder = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);
			long userId = placeOrder.getUserId();
			long tradingId = placeOrder.getTradingId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			BigDecimal earnestAmount = placeOrder.getOrderList().get(0)
					.getOrderPo().getEarnestAmount();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);
			TradingServiceResp fullPlaceOrder = TradingPlaceEngageOrderCallService
					.placeFullPaidOrder(userId, orderId);
			List<Order> engageOrder = fullPlaceOrder.getOrderList().stream()
					.filter(o -> o.getOrderId() == orderId)
					.collect(Collectors.toList());

			String num = TestDataManager.getRandomNum(5);
			List<Order> orders = fullPlaceOrder.getOrderList();
			CreateReturnBillBean bean = new CreateReturnBillBean();
			BigDecimal returnAmount = engageOrder.get(0)
					.getOrderPayableAmount();
			BigDecimal sumReturnAmount = fullPlaceOrder.getPayableAmount();
			Logger.comment("##orderId##:" + orderId);

			String catalogId = orders.get(1).getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = orders.get(1).getOrderDetailPoList().get(0)
					.getProductCount();
			// 订单支付
			tradingService.payOrder(userId, sumReturnAmount,
					fullPlaceOrder.getTradingId());
			// bean=service.setCreateReturnBillBean_AcceptOrder(fullPlaceOrder,tradingService,false);
			tradingService.sellerAcceptOrder(orders.get(1).getSellerId(),
					orderId);

			bean.setOrderId(orderId);
			bean.setReturnAmount(returnAmount);
			bean.setReturnRemark("自动化测试");
			bean.setReturnReasonId(1);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid((int) userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);
			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			bean.setProducts(products);

			Thread.sleep(5000);
			service.callCreateReturnBill(bean, call);
			verifyReturn(fullPlaceOrder, bean, call, 2);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_CreateReturnBill_044_1() {
		Logger.start(true, "正例-创建退货记录--预售商品退货退款,未自动接单，不能走取消流程");
		try {
			// 创建一个预售的订单
			TradingServiceResp placeOrder = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);
			long userId = placeOrder.getUserId();
			long tradingId = placeOrder.getTradingId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			BigDecimal earnestAmount = placeOrder.getOrderList().get(0)
					.getOrderPo().getEarnestAmount();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);
			TradingServiceResp fullPlaceOrder = TradingPlaceEngageOrderCallService
					.placeFullPaidOrder(userId, orderId);
			List<Order> engageOrder = fullPlaceOrder.getOrderList().stream()
					.filter(o -> o.getOrderId() == orderId)
					.collect(Collectors.toList());

			String num = TestDataManager.getRandomNum(5);
			List<Order> orders = fullPlaceOrder.getOrderList();
			CreateReturnBillBean bean = new CreateReturnBillBean();
			BigDecimal returnAmount = engageOrder.get(0)
					.getOrderPayableAmount();
			BigDecimal sumReturnAmount = fullPlaceOrder.getPayableAmount();
			Logger.comment("##orderId##:" + orderId);

			String catalogId = orders.get(1).getOrderDetailPoList().get(0)
					.getCatalogId();
			int returnCount = orders.get(1).getOrderDetailPoList().get(0)
					.getProductCount();
			// 订单支付
			tradingService.payOrder(userId, sumReturnAmount,
					fullPlaceOrder.getTradingId());
			// bean=service.setCreateReturnBillBean_AcceptOrder(fullPlaceOrder,tradingService,false);
			// tradingService.sellerAcceptOrder(orders.get(1).getSellerId(),orderId);

			bean.setOrderId(orderId);
			bean.setReturnAmount(returnAmount);
			bean.setReturnRemark("自动化测试");
			bean.setReturnReasonId(1);
			bean.setReturnType(0);
			bean.setIsRecevied(true);
			bean.setUserid((int) userId);
			bean.setIsYMTHandle(false);
			String pic = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
			List<String> pics = new ArrayList();
			pics.add(pic);
			bean.setPicUrls(pics);

			ProductCatalogModel productModel = new ProductCatalogModel();
			productModel.setCatalogId(catalogId);
			productModel.setReturnCount(returnCount);
			List<ProductCatalogModel> products = new ArrayList<ProductCatalogModel>();
			products.add(productModel);
			bean.setProducts(products);

			Thread.sleep(5000);
			service.callCreateReturnBill(bean, call);

			Logger.verifyEquals(true,
					call.getMsg1().contains("哈尼，已支付定金预售订单不能取消~"), "验证Msg");
			Logger.verifyEquals("201", call.getStatus(), "验证Status");
			Logger.verifyEquals("1", call.getbCode(), "验证bCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	private void verifyReturn(TradingServiceResp tradingServiceResp,
			CreateReturnBillBean bean, CreateReturnBillCall call,
			int... reOrder) throws InterruptedException {
		Thread.sleep(3000);
		Logger.verifyEquals("0", call.getbCode(), "验证bCode");
		// 1:CS_ReturnApplyBill
		CheckCS_ReturnApplyBill(tradingServiceResp, bean, call, reOrder);
		// 2:CS_ReturnApplyProducts
		CheckCS_ReturnApplyProducts(tradingServiceResp, bean, call, reOrder);
		// 3:CS_ReturnApplyPictures
		CheckCS_ReturnApplyPictures(tradingServiceResp, bean, call);
		// 4:CS_ReturnApplyBillLog
		// CheckCS_ReturnApplyBillLog(tradingServiceResp,bean,call,reOrder);
		// 5:CS_FastReturnLog
		// CheckCS_FastReturnLog(tradingServiceResp,bean,call);
	}

	private void CheckCS_ReturnApplyBill(TradingServiceResp tradingServiceResp,
			CreateReturnBillBean bean, CreateReturnBillCall call,
			int... reOrder) throws InterruptedException {
		Logger.comment("#### check CS_ReturnApplyBill ###");
		BigDecimal lastReturnAmount = BigDecimal.valueOf(0L);
		List<ReturnBillList> returnBillLists = call.getCallData()
				.getReturnBillList();
		int count = 0;

		for (int i = 0; i < returnBillLists.size(); i++) {
			count++;
			CS_ReturnApplyBill returnApplyBill = returnApplyBillWapper
					.selectByApplyBillId(returnBillLists.get(i).getReturnId())
					.get(0);
			// CS_ReturnApplyBill beforReturnBill
			// =returnApplyBillWapper.selectByOrderId(bean.getOrderId()).get(0);
			List<CS_ReturnApplyProducts> returnProuductList = Lists
					.newArrayList();

			Logger.verifyEquals(returnApplyBill.getReturnApplyBillId(),
					returnBillLists.get(i).getReturnId(),
					"验证CS_ReturnApplyBill表第" + count + "条ReturnApplyBillId是否正确");
			Logger.verifyEquals(returnApplyBill.getOrderId(),
					bean.getOrderId(), "验证CS_ReturnApplyBill表第" + count
							+ "条OrderId是否正确");
			int sellerId = tradingServiceResp.getOrderList().get(0)
					.getOrderPo().getSellerId().intValue();
			if (reOrder.length == 1)
				sellerId = tradingServiceResp.getOrderList().get(1)
						.getOrderPo().getSellerId().intValue();

			Userinfo buyer = new JUserWapper().selectUserinfoByUid(
					bean.getUserid()).get(0);
			Userinfo seller = new JUserWapper().selectUserinfoByUid(sellerId)
					.get(0);

			Logger.verifyEquals(returnApplyBill.getBuyerId(), bean.getUserid(),
					"验证CS_ReturnApplyBill表第" + count + "条BuyerId是否正确");
			Logger.verifyEquals(returnApplyBill.getBuyerLoginId(),
					buyer.getLoginId(), "验证CS_ReturnApplyBill表第" + count
							+ "条BuyerLoginId是否正确");

			Logger.verifyEquals(
					returnApplyBill.getSellerId(),
					Integer.parseInt(tradingServiceResp.getOrderList().get(0)
							.getOrderPo().getSellerId().toString()),
					"验证CS_ReturnApplyBill表第" + count + "条SellerId是否正确");
			Logger.verifyEquals(returnApplyBill.getSellerLoginId(),
					seller.getLoginId(), "验证CS_ReturnApplyBill表第" + count
							+ "条SellerLoginId是否正确");

			if (returnApplyBill.getOrderStatus() == 2
					|| returnApplyBill.getOrderStatus() == 12)
				Logger.verifyEquals(returnApplyBill.getType(), 0,
						"验证CS_ReturnApplyBill表第" + count + "条Type是否正确");
			else
				Logger.verifyEquals(returnApplyBill.getType(),
						bean.getReturnType(), "验证CS_ReturnApplyBill表第" + count
								+ "条Type是否正确");
			Logger.verifyEquals(returnApplyBill.getReturnRemark(),
					bean.getReturnRemark(), "验证CS_ReturnApplyBill表第" + count
							+ "条ReturnRemark是否正确");
			Logger.verifyEquals(returnApplyBill.getIsDel(), false,
					"验证CS_ReturnApplyBill表第" + count + "条IsDel是否正确");

			BigDecimal amount = new BigDecimal(0);
			OrderPo orderPo = new OrderPo();
			List<OrderDetailPo> orderDetailPoList = new ArrayList();
			BigDecimal totalFreight = BigDecimal.valueOf(0L);
			BigDecimal productTotal = BigDecimal.valueOf(0L);
			BigDecimal couponAmount = BigDecimal.valueOf(0L);
			BigDecimal total = BigDecimal.valueOf(0L);
			BigDecimal freight = BigDecimal.valueOf(0L);
			BigDecimal totalRealFreight = BigDecimal.valueOf(0L);
			BigDecimal totalCancleAmont = BigDecimal.valueOf(0L);// 用于计算取消时的总费用
			if (reOrder.length == 1) {
				amount = orderShardingWapper.selectOrderbyOrderId(
						tradingServiceResp.getOrderList().get(1).getOrderId())
						.getPayableAmount();
				orderPo = orderShardingWapper
						.selectOrderbyOrderId(tradingServiceResp.getOrderList()
								.get(1).getOrderId());
				orderDetailPoList = orderShardingWapper
						.selectOrderDetailbyOrderId(tradingServiceResp
								.getOrderList().get(1).getOrderId());
			} else {
				amount = orderShardingWapper.selectOrderbyOrderId(
						tradingServiceResp.getOrderList().get(0).getOrderId())
						.getPayableAmount();
				orderPo = orderShardingWapper
						.selectOrderbyOrderId(tradingServiceResp.getOrderList()
								.get(0).getOrderId());
				orderDetailPoList = orderShardingWapper
						.selectOrderDetailbyOrderId(tradingServiceResp
								.getOrderList().get(0).getOrderId());
			}
			returnProuductList = returnApplyProductsWapper.selectByOrderId(bean
					.getOrderId());
			for (OrderDetailPo po : orderDetailPoList) {
				// getOrderPrice=商品 * 数量 +商品的总运费
				// productTotal=productTotal.add(po.getProductPrice().multiply(new
				// BigDecimal(po.getProductCount())));
				for (CS_ReturnApplyProducts p : returnProuductList) {
					if (po.getCatalogId().equals(p.getCatalogId())) {
						productTotal = productTotal.add(po.getProductPrice()
								.multiply(new BigDecimal(p.getReturnCount())));
						if (po.getFreeFreight() == false) {
							totalFreight = totalFreight.add(po.getFreight());
							couponAmount = couponAmount
									.add(po.getSellerCouponAmount().add(
											po.getYmtCouponAmount()))
									.add(po.getYmtPromotionAmount())
									.add(po.getPromotionAmount());
						}
					}
				}
				totalCancleAmont = totalCancleAmont.add(po.getProductPrice()
						.multiply(new BigDecimal(po.getProductCount())));
				totalRealFreight = totalRealFreight.add(po.getFreight()); // 所有的运费
			}
			ProductRefundAmountInfo refundAmountInfo = salcula(bean,
					returnBillLists.get(i), totalFreight, productTotal,
					couponAmount, i);
			// 取消
			if (returnApplyBill.getOrderStatus() == 2) {
				Logger.verifyEquals(returnApplyBill.getRealPayAmount()
						.stripTrailingZeros().toPlainString(), totalCancleAmont
						.add(totalRealFreight).subtract(couponAmount)
						.stripTrailingZeros().toPlainString(),
						"验证CS_ReturnApplyBill表第" + count + "条RealPayAmount是否正确");
				Logger.verifyEquals(returnApplyBill.getReturnAmount()
						.stripTrailingZeros().toPlainString(),
						bean.getReturnAmount().stripTrailingZeros()
								.toPlainString(), "验证CS_ReturnApplyBill表第"
								+ count + "条ReturnAmount是否正确");

				Logger.verifyEquals(
						returnApplyBill.getCatalogId(),
						Long.toString(tradingServiceResp.getOrderList().get(0)
								.getOrderId()), "验证CS_ReturnApplyBill表第"
								+ count + "条CatalogId是否正确");
				Logger.verifyEquals(returnApplyBill.getAction(), 20,
						"验证CS_ReturnApplyBill表第" + count
								+ "条Action是否正确，Action=20 表示退货退款完成");
			} else {
				if (i == 0)
					Logger.verifyEquals(
							returnApplyBill.getRealPayAmount()
									.stripTrailingZeros().toPlainString(),
							refundAmountInfo.getMaxRefundableProductAmount()
									.add(totalRealFreight)
									.subtract(couponAmount)
									.stripTrailingZeros().toPlainString(),
							"验证CS_ReturnApplyBill表第" + count
									+ "条RealPayAmount是否正确");
				else
					Logger.verifyEquals(returnApplyBill.getRealPayAmount()
							.stripTrailingZeros().toPlainString(),
							refundAmountInfo.getMaxRefundableProductAmount()
									.subtract(couponAmount)
									.stripTrailingZeros().toPlainString(),
							"验证CS_ReturnApplyBill表第" + count
									+ "条RealPayAmount是否正确");

				if (i != returnBillLists.size() - 1) {
					lastReturnAmount = lastReturnAmount.add(refundAmountInfo
							.getRealRefundProductAmount());
					Logger.verifyEquals(returnApplyBill.getReturnAmount()
							.stripTrailingZeros().toPlainString(),
							refundAmountInfo.getRealRefundProductAmount()
									.stripTrailingZeros().toPlainString(),
							"验证CS_ReturnApplyBill表第" + count
									+ "条ReturnAmount是否正确");
				} else {
					if (bean.getProducts().size() == 1
							&& couponAmount.compareTo(new BigDecimal(0L)) > 0) {

						Logger.verifyEquals(returnApplyBill.getReturnAmount()
								.stripTrailingZeros().toPlainString(),
								refundAmountInfo.getRealRefundProductAmount()
										.stripTrailingZeros().toPlainString(),
								"验证CS_ReturnApplyBill表第" + count
										+ "条ReturnAmount是否正确");
					} else
						Logger.verifyEquals(returnApplyBill.getReturnAmount()
								.stripTrailingZeros().toPlainString(), bean
								.getReturnAmount().subtract(lastReturnAmount)
								.stripTrailingZeros().toPlainString(),
								"验证CS_ReturnApplyBill表第" + count
										+ "条ReturnAmount是否正确");
				}

				Logger.verifyEquals(returnApplyBill.getCatalogId(), bean
						.getProducts().get(i).getCatalogId(),
						"验证CS_ReturnApplyBill表第" + count + "条CatalogId是否正确");
				Logger.verifyEquals(returnApplyBill.getAction(), 1,
						"验证CS_ReturnApplyBill表第" + count
								+ "条Action是否正确，Action=1 表示退货退款完成");
			}

			// Logger.verifyEquals(returnApplyBill.getOrderPrice().stripTrailingZeros().toString(),
			// orderPo.getPayableAmount().stripTrailingZeros().toString(),
			// "验证CS_ReturnApplyBill表第"+count+"条OrderPrice是否正确");
			Logger.verifyEquals(
					returnApplyBill.getOrderPrice().stripTrailingZeros()
							.toString(),
					orderPo.getThirdpartyPaidAmount()
							.add(orderPo.getAccountPaidAmount())
							.stripTrailingZeros().toString(),
					"验证CS_ReturnApplyBill表第" + count + "条OrderPrice是否正确");

			Logger.verifyEquals(
					returnApplyBill.getAccepterUserId(),
					Integer.parseInt(tradingServiceResp.getOrderList().get(0)
							.getOrderPo().getSellerId().toString()),
					"验证CS_ReturnApplyBill表第" + count + "条AccepterUserId是否正确");

			if (tradingServiceResp.getOrderList().get(0).getOrderDetailPoList()
					.get(0).getFreeFreight() == true)
				Logger.verifyEquals(returnApplyBill.getReturnFreihtAmount(),
						refundAmountInfo.getRealRefundFreight(),
						"验证CS_ReturnApplyBill表第" + count
								+ "条ReturnFreihtAmount是否正确");
		}

	}

	/**
	 * 
	 * @param callReturnlist
	 * @param totalFreight
	 *            如果已经退过，则减掉之前的运费
	 * @param totalProduct
	 *            如果已经退过，则减掉之前的商品
	 * @param count
	 * @param isSacula
	 *            当前订单之前是否退单计算过，根据orderId在退单表查询
	 * @return
	 */
	private ProductRefundAmountInfo salcula(CreateReturnBillBean bean,
			ReturnBillList callReturnlist, BigDecimal totalFreight,
			BigDecimal totalProduct, BigDecimal couponAmount, int count) {
		// 计算退款金额和运费
		// List<ProductRefundAmountInfo> lst=Lists.newArrayList();
		// 1:根据退单，查询CS_ReturnApplyProducts，
		totalProduct = totalProduct.subtract(couponAmount);

		ProductRefundAmountInfo info = new ProductRefundAmountInfo();
		CS_ReturnApplyBill returnApplyBill = returnApplyBillWapper
				.selectByApplyBillId(callReturnlist.getReturnId()).get(0);
		List<CS_ReturnApplyProducts> returnProductList = returnApplyProductsWapper
				.selectByApplyBillId(callReturnlist.getReturnId());

		// //未接单 走取消 仅退款 CS_ReturnApplyProducts表一个或者多个个商品一个退单
		// if(returnApplyBill.getOrderStatus()==2)
		// {

		// }
		// //已接单 走退货退款 CS_ReturnApplyProducts表一个商品一个退单
		// else
		// {
		CS_ReturnApplyProducts returnProduct = new CS_ReturnApplyProducts();
		if (returnApplyBill.getOrderStatus() == 2)
			returnProduct = returnProductList.get(count);
		else
			returnProduct = returnProductList.get(0);
		// 2:根据退单的数量 * 单个商品的价格 从CS_ReturnApplyProducts中获取
		BigDecimal maxsSingleProductAmount = returnProduct.getProductPrice()
				.multiply(new BigDecimal(returnProduct.getReturnCount()));
		info.setMaxRefundableProductAmount(maxsSingleProductAmount);
		info.setCatalogId(returnProduct.getCatalogId());
		// 3:如果退款的金额大于商品的最大可退金额，则退款的金额 减 商品的最大可退金额 =运费，再与最大可退运费比较，如果大于 最大可退运费
		// 就断言失败
		// 3.1
		BigDecimal realReturnProuctAmount = BigDecimal.ZERO;
		// 运费一般放在第一个退单商品上
		BigDecimal preReturnFreight = BigDecimal.ZERO;
		if (bean.getReturnAmount().compareTo(totalProduct) > 0)// 退款的金额大于商品的最大可退金额
		{
			preReturnFreight = bean.getReturnAmount().subtract(totalProduct);
			if (preReturnFreight.compareTo(totalFreight) > 0)
				preReturnFreight = preReturnFreight.subtract(couponAmount);
			if (preReturnFreight.compareTo(totalFreight) > 0)// 减掉优惠券若还大于，就断言错误
				Logger.verifyEquals(false, true, "申请的运费不可以大于最大可退运费");
			/*
			 * realReturnProuctAmount=maxsSingleProductAmount
			 * .divide(bean.getReturnAmount())
			 * .multiply(bean.getReturnAmount());
			 */

			if (count == 0) {
				info.setRealRefundFreight(preReturnFreight);
				info.setRealRefundProductAmount(maxsSingleProductAmount.add(
						preReturnFreight).subtract(couponAmount));
			} else {
				info.setRealRefundFreight(BigDecimal.ZERO);
				info.setRealRefundProductAmount(maxsSingleProductAmount);
			}

			// info.setRealRefundProductAmount(bean.getReturnAmount());
		} else// 退款的金额小于后者等于商品的最大可退金额 //接比例计算退款金额
		{
			if (count < bean.getProducts().size() - 1) {
				realReturnProuctAmount = maxsSingleProductAmount
						.divide(totalProduct, 2, RoundingMode.DOWN)
						.multiply(bean.getReturnAmount())
						.setScale(2, RoundingMode.DOWN);

			} else if (bean.getProducts().size() == 1) {
				realReturnProuctAmount = bean.getReturnAmount()
						.subtract(preReturnFreight).subtract(couponAmount);
			}
			info.setRealRefundProductAmount(realReturnProuctAmount);
			// 4:对于同一个订单退过一次，退了部分运费，再次退 如果 退款的金额大于商品的最大可退金额 要把上次的运费减掉 后
			// 获取最大可退运费， 如果大于 最大可退运费 就断言失败

			// }

		}
		return info;

	}

	private void CheckCS_ReturnApplyBill2(
			TradingServiceResp tradingServiceResp, CreateReturnBillBean bean,
			CreateReturnBillCall call) {
		Logger.comment("#### check CS_ReturnApplyBill ###");
		List<ReturnBillList> returnBillLists = call.getCallData()
				.getReturnBillList();
		int count = 0;
		for (int i = 0; i < returnBillLists.size(); i++) {
			count++;
			CS_ReturnApplyBill returnApplyBill = returnApplyBillWapper
					.selectByApplyBillId(returnBillLists.get(i).getReturnId())
					.get(0);
			Logger.verifyEquals(returnApplyBill.getReturnApplyBillId(),
					returnBillLists.get(i).getReturnId(),
					"验证CS_ReturnApplyBill表第" + count + "条ReturnApplyBillId是否正确");
			Logger.verifyEquals(returnApplyBill.getOrderId(),
					bean.getOrderId(), "验证CS_ReturnApplyBill表第" + count
							+ "条OrderId是否正确");
			int sellerId = tradingServiceResp.getOrderList().get(0)
					.getOrderPo().getSellerId().intValue();

			Userinfo buyer = new JUserWapper().selectUserinfoByUid(
					bean.getUserid()).get(0);
			Userinfo seller = new JUserWapper().selectUserinfoByUid(sellerId)
					.get(0);

			Logger.verifyEquals(returnApplyBill.getBuyerId(), bean.getUserid(),
					"验证CS_ReturnApplyBill表第" + count + "条BuyerId是否正确");
			Logger.verifyEquals(returnApplyBill.getBuyerLoginId(),
					buyer.getLoginId(), "验证CS_ReturnApplyBill表第" + count
							+ "条BuyerLoginId是否正确");

			Logger.verifyEquals(
					returnApplyBill.getSellerId(),
					Integer.parseInt(tradingServiceResp.getOrderList().get(0)
							.getOrderPo().getSellerId().toString()),
					"验证CS_ReturnApplyBill表第" + count + "条SellerId是否正确");
			Logger.verifyEquals(returnApplyBill.getSellerLoginId(),
					seller.getLoginId(), "验证CS_ReturnApplyBill表第" + count
							+ "条SellerLoginId是否正确");

			if (returnApplyBill.getOrderStatus() == 2)
				Logger.verifyEquals(returnApplyBill.getType(), 0,
						"验证CS_ReturnApplyBill表第" + count + "条Type是否正确");
			else
				Logger.verifyEquals(returnApplyBill.getType(),
						bean.getReturnType(), "验证CS_ReturnApplyBill表第" + count
								+ "条Type是否正确");

			Logger.verifyEquals(returnApplyBill.getReturnAmount()
					.stripTrailingZeros().toPlainString(), bean
					.getReturnAmount().stripTrailingZeros().toPlainString(),
					"验证CS_ReturnApplyBill表第" + count + "条ReturnAmount是否正确");

			Logger.verifyEquals(returnApplyBill.getReturnRemark(),
					bean.getReturnRemark(), "验证CS_ReturnApplyBill表第" + count
							+ "条ReturnRemark是否正确");
			Logger.verifyEquals(returnApplyBill.getIsDel(), false,
					"验证CS_ReturnApplyBill表第" + count + "条IsDel是否正确");

			BigDecimal amount = new BigDecimal(0);
			OrderPo orderPo = new OrderPo();
			List<OrderDetailPo> orderDetailPoList = new ArrayList();
			BigDecimal totalFreight = new BigDecimal(0);

			amount = orderShardingWapper.selectOrderbyOrderId(
					tradingServiceResp.getOrderList().get(0).getOrderId())
					.getPayableAmount();
			orderPo = orderShardingWapper
					.selectOrderbyOrderId(tradingServiceResp.getOrderList()
							.get(0).getOrderId());
			orderDetailPoList = orderShardingWapper
					.selectOrderDetailbyOrderId(tradingServiceResp
							.getOrderList().get(0).getOrderId());

			for (int k = 0; k < orderDetailPoList.size(); k++) {
				if (orderDetailPoList.get(k).getFreeFreight() == false) {
					totalFreight = totalFreight.add(orderDetailPoList.get(k)
							.getFreight());
				}
			}
			// getOrderPrice=商品 * 数量 +商品的总运费
			BigDecimal productTotal = orderDetailPoList
					.get(1)
					.getProductPrice()
					.multiply(
							new BigDecimal(orderDetailPoList.get(1)
									.getProductCount()));

			Logger.verifyEquals(returnApplyBill.getOrderPrice(),
					orderPo.getPayableAmount(), "验证CS_ReturnApplyBill表第"
							+ count + "条OrderPrice是否正确");

			Logger.verifyEquals(returnApplyBill.getRealPayAmount()
					.stripTrailingZeros().toPlainString(),
					productTotal.add(totalFreight).stripTrailingZeros()
							.toPlainString(), "验证CS_ReturnApplyBill表第" + count
							+ "条RealPayAmount是否正确");
			// ShangouOrder
			Logger.verifyEquals(
					returnApplyBill.getAccepterUserId(),
					Integer.parseInt(tradingServiceResp.getOrderList().get(0)
							.getOrderPo().getSellerId().toString()),
					"验证CS_ReturnApplyBill表第" + count + "条AccepterUserId是否正确");

			// Logger.verifyEquals(returnApplyBill.getOrderStatus(),
			// tradingServiceResp.getOrderList().get(0).getOrderPo().getOrderStatus(),
			// "验证CS_ReturnApplyBill表第"+count+"条OrderStatus是否正确");
			// 取消
			if (returnApplyBill.getOrderStatus() == 2) {
				Logger.verifyEquals(
						returnApplyBill.getCatalogId(),
						Long.toString(tradingServiceResp.getOrderList().get(0)
								.getOrderId()), "验证CS_ReturnApplyBill表第"
								+ count + "条CatalogId是否正确");
				Logger.verifyEquals(returnApplyBill.getAction(), 20,
						"验证CS_ReturnApplyBill表第" + count
								+ "条Action是否正确，Action=20 表示退货退款完成");
			} else {
				Logger.verifyEquals(returnApplyBill.getCatalogId(), bean
						.getProducts().get(0).getCatalogId(),
						"验证CS_ReturnApplyBill表第" + count + "条CatalogId是否正确");
				Logger.verifyEquals(returnApplyBill.getAction(), 1,
						"验证CS_ReturnApplyBill表第" + count
								+ "条Action是否正确，Action=1 表示退货退款完成");
			}
			if (tradingServiceResp.getOrderList().get(0).getOrderDetailPoList()
					.get(0).getFreeFreight() == true)
				Logger.verifyEquals(returnApplyBill.getReturnFreihtAmount(),
						tradingServiceResp.getOrderList().get(0)
								.getOrderFreight(), "验证CS_ReturnApplyBill表第"
								+ count + "条ReturnFreihtAmount是否正确");

		}

	}

	private void CheckCS_ReturnApplyProducts(
			TradingServiceResp tradingServiceResp, CreateReturnBillBean bean,
			CreateReturnBillCall call, int... reOrder)
			throws InterruptedException {

		Logger.comment("#### check CS_ReturnApplyProducts ###");
		List<ReturnBillList> returnBillLists = call.getCallData()
				.getReturnBillList();
		YmtCatalogsIWapper cwapper = new YmtCatalogsIWapper();

		int count = 0;
		for (int i = 0; i < returnBillLists.size(); i++) {
			count++;
			List<CS_ReturnApplyProducts> lst = returnApplyProductsWapper
					.selectByApplyBillId(returnBillLists.get(i).getReturnId());
			Logger.verifyEquals(lst.get(0).getReturnApplyBillId(),
					returnBillLists.get(i).getReturnId(),
					"验证CS_ReturnApplyProducts表第" + count
							+ "条ReturnApplyBillId是否正确");

			int k = 0;
			for (ProductCatalogModel pcmodel : bean.getProducts()) {
				CS_ReturnApplyProducts model = returnApplyProductsWapper
						.selectByCatalogId(pcmodel.getCatalogId());

				YmtCatalogsI catalog = cwapper
						.selectCatalogsByCatalogId(pcmodel.getCatalogId());

				Logger.verifyEquals(model.getProductId(),
						catalog.getsProductId(), "验证CS_ReturnApplyProducts表第"
								+ count + "条ProductId是否正确");
				Logger.verifyEquals(model.getCatalogId(),
						catalog.getsCatalogId(), "验证CS_ReturnApplyProducts表第"
								+ count + "条CatalogId是否正确");
				Logger.verifyEquals(model.getReturnCount(),
						pcmodel.getReturnCount(), "验证CS_ReturnApplyProducts表第"
								+ count + "条returnCount是否正确");

				Logger.verifyEquals(model.getCatalogText(), "属性",
						"验证CS_ReturnApplyProducts表第" + count
								+ "条CatalogText是否正确");

				Logger.verifyEquals(false, model.getIsDel(),
						"验证CS_ReturnApplyProducts表第" + count + "条IsDel是否正确");
				OrderDetailPo orderDetailPo = new OrderDetailPo();
				if (reOrder.length == 1) {
					orderDetailPo = orderShardingWapper
							.selectOrderDetailbyOrderId(
									tradingServiceResp.getOrderList().get(1)
											.getOrderId()).get(k);
				} else {
					orderDetailPo = orderShardingWapper
							.selectOrderDetailbyOrderId(
									tradingServiceResp.getOrderList().get(0)
											.getOrderId()).get(k);
				}

				Logger.verifyEquals(model.getProductPrice(),
						orderDetailPo.getProductPrice(),
						"验证CS_ReturnApplyProducts表第" + count
								+ "条ProductPrice是否正确");
				Logger.verifyEquals(model.getFreight(),
						orderDetailPo.getFreight(),
						"验证CS_ReturnApplyProducts表第" + count + "条Freight是否正确");

				Logger.verifyEquals(model.getOrderId(), bean.getOrderId(),
						"验证CS_ReturnApplyProducts表第" + count + "条OrderId是否正确");
				Logger.verifyEquals(model.getOrderId(), bean.getOrderId(),
						"验证CS_ReturnApplyProducts表第" + count + "条OrderId是否正确");
				Logger.verifyEquals(false, model.getIsPSP(),
						"验证CS_ReturnApplyProducts表第" + count + "条IsPSP是否正确");
				k++;
			}
		}
	}

	// 用户caseTc_CreateReturnBill_005_1 第一个订单的第二个商品
	private void CheckCS_ReturnApplyProducts2(
			TradingServiceResp tradingServiceResp, CreateReturnBillBean bean,
			CreateReturnBillCall call) throws InterruptedException {

		Logger.comment("#### check CS_ReturnApplyProducts ###");
		List<ReturnBillList> returnBillLists = call.getCallData()
				.getReturnBillList();
		YmtCatalogsIWapper cwapper = new YmtCatalogsIWapper();

		int count = 0;
		for (int i = 0; i < returnBillLists.size(); i++) {
			count++;
			List<CS_ReturnApplyProducts> lst = returnApplyProductsWapper
					.selectByApplyBillId(returnBillLists.get(i).getReturnId());
			Logger.verifyEquals(lst.get(0).getReturnApplyBillId(),
					returnBillLists.get(i).getReturnId(),
					"验证CS_ReturnApplyProducts表第" + count
							+ "条ReturnApplyBillId是否正确");

			for (int k = 0; k < bean.getProducts().size(); k++) {
				CS_ReturnApplyProducts model = lst.get(i);
				YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
						.getProducts().get(k).getCatalogId());

				Logger.verifyEquals(model.getProductId(),
						catalog.getsProductId(), "验证CS_ReturnApplyProducts表第"
								+ count + "条ProductId是否正确");
				Logger.verifyEquals(model.getCatalogId(),
						catalog.getsCatalogId(), "验证CS_ReturnApplyProducts表第"
								+ count + "条CatalogId是否正确");
				Logger.verifyEquals(model.getReturnCount(), bean.getProducts()
						.get(k).getReturnCount(), "验证CS_ReturnApplyProducts表第"
						+ count + "条returnCount是否正确");

				Logger.verifyEquals(model.getCatalogText(), "属性",
						"验证CS_ReturnApplyProducts表第" + count
								+ "条CatalogText是否正确");
				Logger.verifyEquals(false, model.getIsDel(),
						"验证CS_ReturnApplyProducts表第" + count + "条IsDel是否正确");
				OrderDetailPo orderDetailPo = orderShardingWapper
						.selectOrderDetailbyOrderId(
								tradingServiceResp.getOrderList().get(0)
										.getOrderId()).get(1);

				Logger.verifyEquals(model.getProductPrice(),
						orderDetailPo.getProductPrice(),
						"验证CS_ReturnApplyProducts表第" + count
								+ "条ProductPrice是否正确");
				Logger.verifyEquals(model.getFreight(),
						orderDetailPo.getFreight(),
						"验证CS_ReturnApplyProducts表第" + count + "条Freight是否正确");
				Logger.verifyEquals(model.getOrderId(), bean.getOrderId(),
						"验证CS_ReturnApplyProducts表第" + count + "条OrderId是否正确");
				Logger.verifyEquals(model.getOrderId(), bean.getOrderId(),
						"验证CS_ReturnApplyProducts表第" + count + "条OrderId是否正确");
				Logger.verifyEquals(false, model.getIsPSP(),
						"验证CS_ReturnApplyProducts表第" + count + "条IsPSP是否正确");
			}
		}
	}

	private void CheckCS_ReturnApplyPictures(
			TradingServiceResp tradingServiceResp, CreateReturnBillBean bean,
			CreateReturnBillCall call) throws InterruptedException {
		Logger.comment("#### check CheckCS_ReturnApplyPictures ###");
		List<ReturnBillList> returnBillLists = call.getCallData()
				.getReturnBillList();
		YmtCatalogsIWapper cwapper = new YmtCatalogsIWapper();

		int count = 0;
		if (returnBillLists.size() > 0) {
			for (int i = 0; i < returnBillLists.size(); i++) {
				count++;
				List<CS_ReturnApplyPictures> lst = returnApplyPictures
						.selectByApplyBillId(returnBillLists.get(i)
								.getReturnId());
				if (bean.getPicUrls() == null || bean.getPicUrls().size() == 0)
					Logger.verifyEquals(lst.size(), 0, "验证数据一致");
				else {
					if (bean.getPicUrls().size() > 0 && lst.size() > 0) {

						for (int k = 0; k < bean.getPicUrls().size(); k++) {
							Logger.verifyEquals(lst.get(k)
									.getReturnApplyBillId(), returnBillLists
									.get(i).getReturnId(),
									"验证CS_ReturnApplyPictures表第" + count
											+ "条ReturnApplyBillId是否正确");
							CS_ReturnApplyPictures model = lst.get(k);
							Logger.verifyEquals(model.getImgUrl(), bean
									.getPicUrls().get(k),
									"验证CS_ReturnApplyPictures表第" + count
											+ "条PicUrls是否正确");
							Logger.verifyEquals(false, model.getIsDel(),
									"验证CS_ReturnApplyPictures表第" + count
											+ "条IsDel是否正确");
						}
					}
				}
			}
		}
	}

	private void CheckCS_ReturnApplyBillLog(
			TradingServiceResp tradingServiceResp, CreateReturnBillBean bean,
			CreateReturnBillCall call, int... reOrder)
			throws InterruptedException {
		Logger.comment("#### check CS_ReturnApplyBillLog ###");
		List<ReturnBillList> returnBillLists = call.getCallData()
				.getReturnBillList();
		OrderPo orderPo = null;
		if (reOrder.length == 1)
			orderPo = orderShardingWapper
					.selectOrderbyOrderId(tradingServiceResp.getOrderList()
							.get(1).getOrderId());
		else
			orderPo = orderShardingWapper
					.selectOrderbyOrderId(tradingServiceResp.getOrderList()
							.get(0).getOrderId());

		if (orderPo.getOrderStatus() == 2)
			Logger.verifyEquals(2, returnBillLists.size(),
					"验证CS_ReturnApplyBillLog数量");
		else
			Logger.verifyEquals(1, returnBillLists.size(),
					"验证CS_ReturnApplyBillLog数量");

		int count = 0;
		for (int i = 0; i < returnBillLists.size(); i++) {
			count++;
			List<CS_ReturnApplyBillLog> lst = returnApplyBillLog
					.selectByApplyBillId(returnBillLists.get(i).getReturnId());
			CS_ReturnApplyBillLog model = lst.get(i);
			Logger.verifyEquals(model.getReturnApplyBillId(), returnBillLists
					.get(i).getReturnId(), "验证CS_ReturnApplyBillLog表第" + count
					+ "条ReturnApplyBillId是否正确");

			if (orderPo.getOrderStatus() == 2 && i == 0) {
				Logger.verifyEquals(1, model.getOperatorType(),
						"验证CS_ReturnApplyBillLog表第" + count
								+ "条OperatorType是否正确");
				Logger.verifyEquals(0, model.getOperatorId(),
						"验证CS_ReturnApplyBillLog表第" + count + "条OperatorId是否正确");
			} else {
				Logger.verifyEquals(2, model.getOperatorType(),
						"验证CS_ReturnApplyBillLog表第" + count
								+ "条OperatorType是否正确");
				Logger.verifyEquals(bean.getUserid(), model.getOperatorId(),
						"验证CS_ReturnApplyBillLog表第" + count + "条OperatorId是否正确");
			}
			if (orderPo.getOrderStatus() == 2 || orderPo.getOrderStatus() == 12)
				Logger.verifyEquals(model.getType(), 0,
						"验证CS_ReturnApplyBillLog表第" + count + "条Type是否正确");
			else
				Logger.verifyEquals(model.getType(), bean.getReturnType(),
						"验证CS_ReturnApplyBillLog表第" + count + "条Type是否正确");
			Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros()
					.toPlainString(), bean.getReturnAmount()
					.stripTrailingZeros().toPlainString(),
					"验证CS_ReturnApplyBillLog表第" + count + "条ReturnAmount是否正确");
			Logger.verifyEquals(
					model.getReturnRemark(),
					null,
					"验证CS_ReturnApplyBillLog表第"
							+ count
							+ "条ReturnRemark是否正确(目前与CS_ReturnApplyBill表中的ReturnRemark不一致，log没有加备注)");
			// ReturnBillAction
			// AccepterLoginId
			// AccepterType
			// Remark
			// OperatorName
			// AccepterUserId
		}
	}

	private void CheckCS_FastReturnLog(TradingServiceResp tradingServiceResp,
			CreateReturnBillBean bean, CreateReturnBillCall call)
			throws InterruptedException {
		Logger.comment("#### check CS_FastReturnLog ###");
		List<ReturnBillList> returnBillLists = call.getCallData()
				.getReturnBillList();
		YmtCatalogsIWapper cwapper = new YmtCatalogsIWapper();
		int count = 0;
		for (int i = 0; i < returnBillLists.size(); i++) {
			count++;
			List<CS_FastReturnLog> lst = fastReturnLog
					.selectByApplyBillId(returnBillLists.get(i).getReturnId());

			for (int k = 0; k < lst.size(); k++) {
				CS_FastReturnLog model = lst.get(k);
				Logger.verifyEquals(model.getReturnApplyBillId(),
						returnBillLists.get(i).getReturnId(),
						"验证CS_FastReturnLog表第" + count
								+ "条ReturnApplyBillId是否正确");
				Userinfo buyer = new JUserWapper().selectUserinfoByUid(
						bean.getUserid()).get(0);
				YmtCatalogsI catalog = cwapper.selectCatalogsByCatalogId(bean
						.getProducts().get(k).getCatalogId());

				Logger.verifyEquals(model.getBuyerId(), bean.getUserid(),
						"验证CS_ReturnApplyProducts表第" + count + "条BuyerId是否正确");
				Logger.verifyEquals(model.getBuyerLevel(),
						buyer.getUserLevel(), "验证CS_ReturnApplyProducts表第"
								+ count + "条UserLevel是否正确");
				Logger.verifyEquals(model.getSellerId(), catalog.getiUserId(),
						"验证CS_ReturnApplyProducts表第" + count + "条SellerId是否正确");
				Logger.verifyEquals(model.getReturnAmount(),
						bean.getReturnAmount(), "验证CS_ReturnApplyProducts表第"
								+ count + "条ReturnAmount是否正确");

				// OrderstaWithApply
				// FaseApplyTime
			}
		}
	}

}
